<?php $rep = $tree->getContent(); ?>
<h1>Edycja drzewa dla zasad gry <?php echo $rules->getName() ?></h1>
<div id="info">
    <span id="info_label1"><?php echo $tree->getPlayerLabel(0) ?></span>
    <span id="info_label2"><?php echo $tree->getPlayerLabel(1) ?></span>
    <span id="info_count"><?php echo $rep->count() ?></span>
    <span id="info_free_pts"><?php echo $rules->getFreePts() ?></span>
    <span id="info_end_value"><?php echo $tree->getMatchEndType() ?></span>
    <span id="info_end_type"><?php echo $tree->getMatchEndType() ?></span>
    <span id="info_rule_name"><?php echo $rules->getName() ?></span>
    <span id="info_id_rule"><?php echo $rules->getId() ?></span>
    <span id="info_win_type"><?php echo $tree->getWinPoints() ?></span>
    
    <?php foreach ($rep as $i => $node): ?>
        <?php
        switch ($node->getType()) {
            case GameRules::$TN_PLAYER1:
            case GameRules::$TN_PLAYER2:
                ?>
                <span id="info_node<?php echo $node->getId() ?>id"><?php echo $node->getId() ?></span>
                <span id="info_node<?php echo $node->getId() ?>label"><?php echo $node->getLabel() ?></span>
                <span id="info_node<?php echo $node->getId() ?>type"><?php echo $node->getType() ?></span>
                <span id="info_node<?php echo $node->getId() ?>group"><?php echo $node->getGroup(); ?></span>
                <?php foreach ($node->getActions() as $action => $value) { ?>
                    <span id="info_node<?php echo $node->getId() ?>action_count"><?php echo $node->getActions()->count() ?></span>    
                    <span id="info_node<?php echo $node->getId() ?>action<?php echo $action ?>"><?php echo $action ?></span>
                    <span id="info_node<?php echo $node->getId() ?>action<?php echo $action ?>label"><?php echo $value[0] ?></span>
                    <span id="info_node<?php echo $node->getId() ?>action<?php echo $action ?>value"><?php echo $value[1] ?></span>
                    <?php
                }
                break;
            case GameRules::$TN_NATURE:
                ?>
                <span id = "info_node<?php echo $node->getId() ?>id"><?php echo $node->getId() ?></span>
                <span id="info_node<?php echo $node->getId() ?>label"><?php echo $node->getLabel() ?></span>
                <span id="info_node<?php echo $node->getId() ?>type"><?php echo $node->getType() ?></span>
                <?php foreach ($node->getActions() as $action => $value) { ?>
                    <span id="info_node<?php echo $node->getId() ?>action_count"><?php echo $node->getActions()->count() ?></span>     
                    <span id="info_node<?php echo $node->getId() ?>action<?php echo $action ?>"><?php echo $action ?></span>
                    <span id="info_node<?php echo $node->getId() ?>action<?php echo $action ?>label"><?php echo $value[0] ?></span>
                    <span id="info_node<?php echo $node->getId() ?>action<?php echo $action ?>probability"><?php echo $value[1] ?></span>
                    <span id="info_node<?php echo $node->getId() ?>action<?php echo $action ?>value"><?php echo $value[2] ?></span>
                    <?php
                }
                break;
            case GameRules::$TN_POINTS:
                ?>
                <span id = "info_node<?php echo $node->getId() ?>id"><?php echo $node->getId() ?></span>
                <span id="info_node<?php echo $node->getId() ?>type"><?php echo $node->getType() ?></span>
                <span id="info_node<?php echo $node->getId() ?>label"><?php echo $node->getLabel() ?></span>
                <span id="info_node<?php echo $node->getId() ?>points1"><?php echo $node->getPlayerPoints(0); ?></span>
                <span id="info_node<?php echo $node->getId() ?>points2"><?php echo $node->getPlayerPoints(1); ?></span>    
                <?php
                break;
        }
        ?>

        <br />
    <?php endforeach ?>
</div>
    <form id="tree_form" action="<?php echo url_for('@mod_rules_tree_rep_update') ?>">    
        
    <div id="tree_rep">        
        <div id="tree"></div>
        <div style='margin-bottom: 10px'><a id="node_add" class="content_option" href="#" title="Dodaj nowy węzeł"><img class="option_img" src="/images/iAdd.png">dodaj</a></div>
        <input id="validate_tree" type="button" value="Podgląd drzewa" style="margin:0px auto 20px auto" title="Sprawdź poprawność wprowadzonych danych i wygeneruj podgląd drzewa"/><br />
        <div id="tree_preview"></div>
        <input type="submit" value="Zapisz" style="margin:0px auto 50px auto" />  
    </div>   

